//
//  BFCenterController.m
//  beifang
//
//  Created by Apple on 17/4/12.
//  Copyright © 2017年 郭凯. All rights reserved.
//

#import "BFCenterController.h"
#import "BFVideoPlayer.h"
@interface BFCenterController ()<ZFPlayerDelegate>
@property (strong, nonatomic) IBOutlet UIView *targetView;
@property(nonatomic,strong)ZFPlayerView *playerView;
@property (nonatomic,strong) BFVideoPlayer* videoPlayer;
@end

@implementation BFCenterController
-(BFVideoPlayer *)videoPlayer{
    if (!_videoPlayer) {
        _videoPlayer = [[BFVideoPlayer alloc]init];
    }
    return _videoPlayer;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor purpleColor];
    self.title = @"用户中心";
    
    //初始化父类视图
    UIView *fatherView = [[UIView alloc]init];
    fatherView.backgroundColor = [UIColor redColor];
    fatherView.frame = CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*(9/16.0));
    [self.view addSubview:fatherView];
    //初始化播放控制视图
    ZFPlayerControlView *controlView = [[ZFPlayerControlView alloc] init];
    
    // model
    ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
    playerModel.fatherView = fatherView;
    playerModel.videoURL = [NSURL URLWithString:@"http://baobab.wdjcdn.com/1456459181808howtoloseweight_x264.mp4"];
    playerModel.title = @"视频标题";
    
    //初始化ZFPlayerView
    self.playerView = [[ZFPlayerView alloc] init];
    [self.playerView playerControlView:controlView playerModel:playerModel];
    self.playerView.delegate = self;
//    [self.playerView autoPlayTheVideo];
    self.playerView.playerLayerGravity = ZFPlayerLayerGravityResizeAspect;
    
    
    
}
/** 返回按钮事件 */
- (void)zf_playerBackAction{

    NSLog(@"点击返回");
}
/** 下载视频 */
- (void)zf_playerDownload:(NSString *)url{
    NSLog(@"下载视频=%@",url);

}
- (IBAction)player:(id)sender {
  NSURL *url = [NSURL URLWithString:@"http://baobab.wdjcdn.com/1456459181808howtoloseweight_x264.mp4"];
    [self.videoPlayer playVideo:url targetView:self.targetView];
}
- (IBAction)resume:(id)sender {
    [self.videoPlayer resume];
}
- (IBAction)pause:(id)sender {
    [self.videoPlayer pasue];
}
@end
